define(['moment','jquery', 'bootstrap', 'backend',"highcharts",'echarts','table','form','jquery-ui', 'bootstrap-datetimepicker'], function (moment,$, undefined, Backend,Highcharts,echarts, Table, Form,jqueryui, bootstrapdatetimepicker) {
    var operas=0;
    var yesterday=null;
    Date.prototype.Format = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1, //月份
                "d+": this.getDate(), //日
                "H+": this.getHours(), //小时
                "m+": this.getMinutes(), //分
                "s+": this.getSeconds(), //秒
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                "S": this.getMilliseconds() //毫秒
            };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
    };
    Number.prototype.toFixed = function (s) {
        var that = this, changenum, index;
        if (this < 0) {
            that = -that;
        }
        changenum = (parseInt(that * Math.pow(10, s) + 0.5) / Math.pow(10, s)).toString();
        index = changenum.indexOf(".");
        if (index < 0 && s > 0) {
            changenum = changenum + ".";
            for (var i = 0; i < s; i++) {
                changenum = changenum + "0";
            }
        } else {
            index = changenum.length - index;
            for (var i = 0; i < (s - index) + 1; i++) {
                changenum = changenum + "0";
            }
        }
        if (this <0) {
           changenum = -changenum;
        }
        return changenum;
    };
    var Controller = {

        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'resources/resc/addtabs',
                   /* add_url: 'reportdata/add',
                    edit_url: 'reportdata/edit',
                    del_url: 'reportdata/del',
                    multi_url: 'reportdata/multi',
                    testcycle: 'reportdata/testcycle',
                    detail: 'reportdata/detail',
                    exec: 'reportdata/exec',
                    stop: 'reportdata/stop',
                    realresults: 'reportdata/results',
                    historyresults: 'reportdata/historyresults',
                    realtotals: 'reportdata/realtotals',
                    table: 'missionlist',
                    select_probe: 'reportdata/select_probe',*/
                }
            });
            $('#daytime').datetimepicker({
                locale: moment.locale('zh-cn') //引入中文语言
                // language:  'zh-CN',  //日期
            });
            require(['jstree'], function () {
                //全选和展开
                $(document).on("click", "#checkall", function () {
                    $("#channeltree").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
                });
                $(document).on("click", "#expandall", function () {
                    $("#channeltree").jstree($(this).prop("checked") ? "open_all" : "close_all");
                });
                $(".content").click();
                $('#channeltree').bind("changed.jstree", function (e, data) {
                    var treeNode = $('#channeltree').jstree(true).get_selected(true)[0]; //获取所有选中的节点对象
                    if(!treeNode){
                        operas='0';
                        return false;
                    }
                    if(operas==treeNode.id){
                       return false;
                    }
                    operas=treeNode.id;
                    var treeNodeParents = treeNode.parents.slice(0,-1);
                    treeNodeParents.push(treeNode.original.id);
                    var getlevel = Controller.getlevel(treeNodeParents.join(","));
                    $(".titles").html(getlevel.tag_name+'详情');
                    $('#ids').html(getlevel.is_sign);
                    $('#name').html(getlevel.tag_name);
                    $('#tag_id').html(getlevel.tag_id);
                    $('#template_id').html(getlevel.template_id);
                    document.getElementById("first").className = 'tab-pane fade';
                    document.getElementById("second").className = 'tab-pane fade';
                    document.getElementById("third").className = 'tab-pane fade';
                    document.getElementById("four").className = 'tab-pane fade';
                    document.getElementById("five").className = 'tab-pane fade';
                    document.getElementById("six").className = 'tab-pane fade';
                    document.getElementById("seven").className = 'tab-pane fade';
                    var curDate = new Date();
                    yesterday = new Date(curDate.getTime() - 24*60*60*1000).Format("yyyy-MM-dd");; //前一天
                    $("#daytime").val(yesterday);
                    var dayTime = new Date(yesterday).Format("yyyy年MM月dd日");
                    $("#regionlinkname1").html("天隆拨测"+dayTime+'拨测结果');
                    $("#daytime").attr("placeholder",yesterday);
                    $("#table4").bootstrapTable('destroy', {});
                    $("#table").bootstrapTable('destroy', {});
                    $("#tablesum").bootstrapTable('destroy', {});
                    $("#toolbar").hide();
                    $("#toolbarsum").hide();
                    $("#toolbar4").hide();
                    $("#tablea7").hide();
                    if(getlevel.template_id=="1"){
                            document.getElementById("first").className = 'tab-pane fade active in';
                            $("#tabtitle").html(getlevel.tag_name+'出口流量表');
                            $("#getlevel").val(JSON.stringify(getlevel));
                            $('#regionlink1').html("");
                            $('#regionlink2').html("");
                            $("#toolbar").show();
                            $("#toolbarsum").show();
                            if(getlevel.tag_name=='深圳天威'){
                                $("#flow_pu1").show();
                                $("#flow_pu1").attr("class","col-md-3");
                                $("#flow_pu").attr("class","col-md-6");
                                $("#flow_pu2").attr("class","col-md-3");
                                $("#toolbarsum").hide();
                                $("#tablesum").hide();
                            }else{
                                $("#flow_pu1").hide();
                                $("#flow_pu").attr("class","col-md-6");
                                $("#flow_pu2").attr("class","col-md-6"); 
                                $("#toolbarsum").show();
                                $("#tablesum").show();
                            }
                            setTimeout(function () {
                               Controller.probequality('#toolbar',"table");
                            }, 500);
                            setTimeout(function () {
                               Controller.probequalitysum();
                            }, 1000);
                            Controller.requestdata();
                            Controller.bc_top();
                            $('.td').css('border', '1px solid #999');
                            $('.th').css('border', '1px solid #999');
                    }else if(getlevel.template_id=="2"){//河北
                            document.getElementById("third").className = 'tab-pane fade active in';
                            $("#tbo").html("");
                            Controller.table3();
                    }else if(getlevel.template_id=="3"){//湖南
                            document.getElementById("four").className = 'tab-pane fade active in';
                            $("#toolbar4").show();
                            Controller.probequality('#toolbar4',"table4");
                            //Controller.huntable();
                    }else if(getlevel.template_id=="4"){//歌华
                            document.getElementById("five").className = 'tab-pane fade active in';
                            Controller.ghtable();
                    }else if(getlevel.template_id=="5"){//航数宽网
                            document.getElementById("six").className = 'tab-pane fade active in';
                            Controller.hskwtable();
                    }else if(getlevel.template_id=="6"){//北方联合
                            document.getElementById("seven").className = 'tab-pane fade active in';
                            $("#tablea7").show();
                            Controller.bflhtable();
                    }else if(getlevel.template_id=="7"){//大连天途
                            document.getElementById("seven").className = 'tab-pane fade active in';

                            Controller.bflhtable();
                    }else{
                            document.getElementById("second").className = 'tab-pane fade active in';
                            $("#nametb2").html("");
                            Controller.table2();
                    }
                    $('tr').children("td").css("border","1px solid #444");
                    $('tr').children("th").css("border","1px solid #444");
                    return false;
                });
                // blur.jstree 编辑生效
                /*$('#channeltree').bind("set_text.jstree", function (event, data) {
                    // createCategory(event, data);
                });
                function layerframe(title,framepid,frameid,sign){
                    layer.open({
                        offset: '60px', //右下角弹出
                        type: 2,
                        area: ['50%','60%'],
                        fix: false, //不固定
                        maxmin: true, //显示或者隐藏缩小 放大 按钮
                        shadeClose: false,//锁定当前页面必须点 X 才能关闭此页面
                        shade:0.4,
                        title: title,
                        content: '/admin/reportdata/qualitytree?pid=' + framepid + "&id=" + frameid + "&sign=" + sign,
                    });
                }
                function layerframeAttr(title,framepid,pid){
                    layer.open({
                        offset: '60px', //右下角弹出
                        type: 2,
                        area: ['50%','60%'],
                        fix: false, //不固定
                        maxmin: true, //显示或者隐藏缩小 放大 按钮
                        shadeClose: false,//锁定当前页面必须点 X 才能关闭此页面
                        shade:0.4,
                        title: title,
                        content: '/admin/reportdata/treeattr?pid=' + framepid +'&pid2='+pid,
                    });
                }
                function layerframeThree(title,framepid,pid){
                    layer.open({
                        offset: '60px', //右下角弹出
                        type: 2,
                        area: ['50%','60%'],
                        fix: false, //不固定
                        maxmin: true, //显示或者隐藏缩小 放大 按钮
                        shadeClose: false,//锁定当前页面必须点 X 才能关闭此页面
                        shade:0.4,
                        title: title,
                        content: '/admin/reportdata/treeattr_three?pid=' + framepid +'&pid2='+pid,
                    });
                }*/
                // console.log(tagList);
                $('#channeltree').jstree({
                    "themes": {
                        "stripes": true,
                    },
                    "checkbox": {
                        "keep_selected_style": false,
                        "three_state": false, //如果想选择父节点时不全选子节点，就需要加上下面这句
                    },
                    "types": {
                        "channel": {
                            "icon": "fa fa-file-o",
                        },
                        "list": {
                            "icon": "fa fa-folder-o",  //非任务图标
                        },
                        "link": {
                            "icon": "fa fa-link",
                        },
                        "disabled": {
                            "check_node": false,
                            "uncheck_node": false
                        }
                    },
                    // "state"
                    'plugins': ["types", "checkbox","contextmenu"],
                    // "contextmenu":{
                    //     "items" : customMenu,
                    //     "select_node":false,//取消右击选中事件
                    // },
                    "core": {
                        // "multiple": true,
                        "multiple": false,//单选
                        'check_callback': true,
                        "data": tagList
                    }
                });
            });
           //  刷新树
            $(document).on('click',".btn-tree",function(){
                //  获取当前页面的utl
                var url =  window.location.href;
                location.reload(url);
            })
            //更新昨日统计
            $(document).on("click", ".update-day", function () {
                var ids = $("#ids").html();
                var time=$("#daytime").val();
                var tag_id = $("#tag_id").html();
                $.ajax({
                    url: 'regionday/update_day',
                    type:'post',
                    data:{ids:ids,time:time},
                    //data: {ids:ids},
                    dataType:'json',
                    beforeSend: function () {
                             i = layer.msg('更新中请稍等...', {icon: 16,shade: [0.5, '#393D49'],scrollbar: false,offset:'50%',time:60*1000});
                        },
                    success:function(json){
                        layer.close(i);
                        layer.alert(json.msg);
                        $(".btn-ref").click();
                    }
                });
            });
           // 搜索绥化广电
           $("#search_task").click(function(){
                var template_id = $('#template_id').html();
                var time=$("#daytime").val();
                var dayTime = new Date(time).Format("yyyy年MM月dd日");
                $("#regionlinkname1").html("天隆拨测"+dayTime+'拨测结果');
                if(template_id=='1'){
                    $("#tr1").html('<td colspan="4" style="text-align: center;">正在努力地加载数据中，请稍后......</td>');
                    $('#regionlink1').html("");
                    $('#regionlink2').html("");
                    //$("#table").bootstrapTable('destroy', {});
                    //$("#tablesum").bootstrapTable('destroy', {});
                    Controller.requestdata();
                    Controller.bc_top();
                    $("#table").bootstrapTable('refresh');
                    setTimeout(function () {
                       //Controller.probequalitysum();
                       $("#tablesum").bootstrapTable('refresh');
                    }, 50);

                }else if(template_id=='2'){//河北
                    $("#tbo").html("");
                    $("#thtext3").show();
                    //setTimeout(function () {
                        Controller.table3();
                    //}, 100);
                }else if(template_id=='3'){//湖南
                    $("#nametb4").html("");
                    $("#thtext4").show();
                   // setTimeout(function () {
                      //  Controller.huntable();
                      $("#table4").bootstrapTable('refresh');
                   // }, 100);
                 }else if(template_id=="4"){//歌华
                    $("#tbo5").html("");
                    $("#thtext5").show();
                   // setTimeout(function () {
                        Controller.ghtable();
                   // }, 100);
                }else if(template_id=="5"){//航数宽网
                    $("#tbo6").html("");
                    $("#thtext6").show();
                   // setTimeout(function () {
                        Controller.hskwtable();
                   // }, 100);
                }else if(template_id=="6"){//北方联合
                    $("#tr7").html('<td colspan="4" style="text-align: center;">正在努力地加载数据中，请稍后......</td>');
                    $("#tbo7").html("");
                    $("#thtext7").show();
                   // setTimeout(function () {
                        Controller.bflhtable();
                   // }, 100);
                }else if(template_id=="7"){//北方联合
                    $("#tbo7").html("");
                    $("#thtext7").show();
                    Controller.bflhtable();
                }else{
                    $("#nametb2").html("");
                    $("#thtext2").show();
                   // setTimeout(function () {
                        Controller.table2();
                   // }, 100);
                }
                $('tr').children("td").css("border","1px solid #444");
                $('tr').children("th").css("border","1px solid #444");
            })
            //  重置绥化广电
            $("#reset_task").click(function(){
                var curDate = new Date();
                var time = new Date(curDate.getTime() - 24*60*60*1000).Format("yyyy-MM-dd");; //前一天
                $("#daytime").val(time);
                var dayTime = new Date(time).Format("yyyy年MM月dd日");
                $("#regionlinkname1").html("天隆拨测"+dayTime+'拨测结果');
                var template_id = $('#template_id').html();
                if(template_id=='1'){//绥化
                    $("#tr1").html('<td colspan="4" style="text-align: center;">正在努力地加载数据中，请稍后......</td>');
                    $('#regionlink1').html("");
                    $('#regionlink2').html("");
                    Controller.requestdata();
                    Controller.bc_top();
                    $("#table").bootstrapTable('refresh');
                    setTimeout(function () {
                       $("#tablesum").bootstrapTable('refresh');
                    }, 50);
                    //Controller.probequality();
                    //Controller.probequalitysum();
                }else if(template_id=='2'){//河北
                    $("#tbo").html("");
                    $("#thtext3").show();
                    //setTimeout(function () {
                        Controller.table3();
                    //}, 50);
                }else if(template_id=='3'){//湖南
                    $("#nametb4").html("");
                    $("#thtext4").show();
                    //setTimeout(function () {
                       // Controller.huntable();
                       $("#table4").bootstrapTable('refresh');
                    //}, 100);
                 }else if(template_id=="4"){//歌华
                    $("#tbo5").html("");
                    $("#thtext5").show();
                   // setTimeout(function () {
                        Controller.ghtable();
                   // }, 100);
                }else if(template_id=="5"){//航数宽网
                    $("#tbo6").html("");
                    $("#thtext6").show();
                   // setTimeout(function () {
                        Controller.hskwtable();
                   // }, 100);
                 }else if(template_id=="6"){//北方联合
                    $("#tr7").html('<td colspan="4" style="text-align: center;">正在努力地加载数据中，请稍后......</td>');
                    $("#tbo7").html("");
                    $("#thtext7").show();
                   // setTimeout(function () {
                        Controller.bflhtable();
                   // }, 100);
                }else if(template_id=="7"){
                    $("#tbo7").html("");
                    $("#thtext7").show();
                    Controller.bflhtable();
                }else{
                    $("#nametb2").html("");
                    $("#thtext2").show();
                    //setTimeout(function () {
                        Controller.table2();
                    //}, 100);
                 }
                 $('tr').children("td").css("border","1px solid #444");
                 $('tr').children("th").css("border","1px solid #444");
            })

            //刷新绥化广电
            $(document).on("click",".btn-ref",function(){
                var template_id = $('#template_id').html();
                if(template_id=='1'){//绥化
                    $("#tr1").html('<td colspan="4" style="text-align: center;">正在努力地加载数据中，请稍后......</td>');
                    $('#regionlink1').html("");
                    $('#regionlink2').html("");
                    $("#table").bootstrapTable('refresh');
                    setTimeout(function () {
                        Controller.requestdata();
                        Controller.bc_top();
                        $("#tablesum").bootstrapTable('refresh');
                    }, 50);
                }else if(template_id=='2'){//河北
                    $("#tbo").html("");
                    $("#thtext3").show();
                    setTimeout(function () {
                        Controller.table3();
                    }, 50);
                }else if(template_id=='3'){//湖南
                    $("#nametb4").html("");
                    $("#thtext4").show();
                    setTimeout(function () {
                        //Controller.huntable();
                        $("#table4").bootstrapTable('refresh');
                    }, 50);
                }else if(template_id=="4"){//歌华
                    $("#tbo5").html("");
                    $("#thtext5").show();
                    setTimeout(function () {
                        Controller.ghtable();
                    }, 50);
                }else if(template_id=="5"){//航数宽网
                    $("#tbo6").html("");
                    $("#thtext6").show();
                    setTimeout(function () {
                        Controller.hskwtable();
                    }, 50);
                }else if(template_id=="6"){//北方联合
                    $("#tr7").html('<td colspan="4" style="text-align: center;">正在努力地加载数据中，请稍后......</td>');
                    $("#tbo7").html("");
                    $("#thtext7").show();
                    setTimeout(function () {
                        Controller.bflhtable();
                    }, 50);
                }else if(template_id=="7"){
                    $("#tbo7").html("");
                    $("#thtext7").show();
                    setTimeout(function () {
                        Controller.bflhtable();
                    }, 50);
                }else{
                    $("#nametb2").html("");
                    $("#thtext2").show();
                    setTimeout(function () {
                        Controller.table2();
                    }, 50);
                }
                setTimeout(function () {
                    $('tr').children("td").css("border","1px solid #444");
                    $('tr').children("th").css("border","1px solid #444");
                }, 50);
            });

            $(document).on("click",".contendhref",function(){
                var btn_obj = $(this);
                var id = $(btn_obj).attr('contend');
                var name = $(btn_obj).attr('name');
                //layerframe("趋势图",id,name,'5');
                Fast.api.open("/screen/drawing/detail?id="+id+'&name='+name+'&type=5',name+"-趋势图",{area:['80%', '88%']});
            });

            //  发送按钮
            $(".btn-shot").click(function(event){
                var treeNode = $('#channeltree').jstree(true).get_selected(true)[0];
                var treeNodeParents = treeNode.parents.slice(0,-1);
                treeNodeParents.push(treeNode.original.id);
                var getlevel = Controller.getlevel(treeNodeParents.join(","));
                var tagname = getlevel.tag_name;
                var curWWWPath = window.document.location.href;
                var pathname = window.document.location.pathname;
                var pos = curWWWPath.indexOf(pathname);
                var localhostPath = curWWWPath.substring( 0, pos );
                var url = localhostPath+'/dashboard/regionday?tagname='+tagname+'&type=send';
                window.open(url);
                // Fast.api.open("/dashboard/regionday?tagname="+tagname,{area:['100%', '100%']});
            })
         },
         bc_top: function() {
            // 基于准备好的dom，初始化echarts实例
            var myChart = echarts.init(document.getElementById('echart1'));
            var time=$("#daytime").val();
            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            $.ajax({
                type:"POST",
                url: "/dashboard/regionday/bc_top",
                data:{ids:ids,time:time,name:name},
                dataType:"json",
                // async: false,
                success:function(json){
                    //if(json.code==1){
                        var key_str = [];
                        var in_str = [];
                        $.each(json.data,function(index,item){
                            key_str.push(item.key);
                            in_str.push(item.value);
                        })
                        
                        option = {
                            //  backgroundColor: '#00265f',
                            color: ['#3398DB'],
                            tooltip: {
                                trigger: 'axis',
                                axisPointer: {
                                    type: 'line'
                                },
                                /*formatter:function(params, ticket, callback){
                                    var tipString = params[0].axisValue + "<br />";
                                    var indexColor;
                                    for (var i = 0, length = params.length; i < length; i++) {
                                        var item_val = params[i].value;
                                        var item_val_str = item_val.toFixed(2);
                                        indexColor = params[i].color;
                                        tipString += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background:' + indexColor + '"></span>';
                                        tipString += '<span style="color:#fff" data-type ="lineTip" data-val=' + params[i].value / 1000 / 1000 + '>' + params[i].seriesName + '：' + item_val_str + '</span><br />';
                                    }
                                    return tipString;
                                }*/
                            },

                            grid: {
                                left: '0%',
                                top: '10%',
                                right: '2%',
                                bottom: '2%',
                                containLabel: true
                            },
                            
                            xAxis: [{
                                type: 'category',
                                data: key_str,
                                //data: ['济南->安徽', '广州->福州', '长沙->深圳', '台州->杭州', '深圳->福建', '北京->河北', '河北->河南'],
                            }],
                            yAxis: [{
                                type: 'value',
                            }],
                            series: [{
                                name:json.name,
                                type: 'bar',
                                data: in_str,
                                //data: [2, 3, 3, 9, 15, 9, 15],
                                barWidth: '40%', //柱子宽度
                                barGap: 1, //柱子之间间距
                                itemStyle: {
                                    normal: {
                                        color: '#00b050',
                                        opacity: 1,
                                        barBorderRadius: 5,
                                        label: {
                                            show: true,
                                            position: "top",
                                            textStyle: {
                                                fontWeight: "bolder",
                                                fontSize: "12",
                                                color: "#444"
                                            }
                                        }
                                    }
                                }
                            }
                            ]
                        };
                        // 使用刚指定的配置项和数据显示图表。
                        myChart.setOption(option);
                        window.addEventListener("resize", function () {
                            myChart.resize();
                        });
                    //}
                }
            });
        },
        layerframe:function(title,frameid,framename,sign){
            layer.open({
                offset: '60px', //右下角弹出
                type: 2,
                area: ['80%','88%'],
                fix: false, //不固定
                maxmin: false, //显示或者隐藏缩小 放大 按钮
                shadeClose: false,//锁定当前页面必须点 X 才能关闭此页面
                shade:0.4,
                title: framename+'-'+title,
                content: '/screen/drawing/detail?id=' + frameid + "&name=" + framename + "&type=" + sign,
            });
        },
        huntable:function(){
            var table4 = $("#table4");

            var time=$("#daytime").val();
            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            table4.bootstrapTable('refresh');
            table4.bootstrapTable('destroy');
            table4.bootstrapTable({
                    url:'point/regionday/huntable?name='+name+'&ids='+ids+'&time='+time,
                    extend: {
                        table: 'region_monitor_contentday',
                    },
                    toolbar: '#toolbar4',
                    sortName: 'a.id',
                    columns: [
                        [
                            /*{field: 'id', title:__('ID'),formatter: function(value,row,index){
                                    return row.id;
                            }},*/
                            {field: 'regionname', title:__('项目名称')},
                            {field: 'resourcename', title: __('资源'),operate:false,placeholder: __('模糊查询')},
                            {field: 'exportname', title: __('出口'),operate:false,placeholder: __('模糊查询')},
                            {field: 'band', title: __('带宽(G)'),operate:false,formatter:function(value,row,index){
                                if(value==null||value==''){
                                    return 'N/A';
                                }else{
                                     return parseFloat(value).toFixed(2);
                                }

                            }},
                            {field: 'values', title: __('实际使用带宽(G)'),operate:false,formatter:function(value,row,index){
                                return (row.values/1000000000).toFixed(2);
                            }},
                            {field: 'valuserate', title: __('带宽使用率'),cellStyle:Controller.cellStyle,operate:false,formatter:function(value,row,index){
                                if(row.band==null||row.band==''){
                                    return 'N/A';
                                }else{
                                     return row.valuserate+'%';
                                }

                            }},
                            /*{field: 'exportstatus', title: __('出口计算'),searchList:{"1":__('正'),"0":__('负')},align: 'center',formatter: Table.api.formatter.status},*/
                            {field: 'totleflow', title: __('实际流量(G)'),operate:false,formatter:function(value,row,index){
                                    if(row.totleflow==null||row.totleflow==''){
                                        return 'N/A';
                                    }else{
                                          return parseFloat(row.totleflow).toFixed(2);
                                    }

                            }},
                            {field: 'totlerate', title: __('服务流量占比'),cellStyle:Controller.serverPercent,operate:false,formatter:function(value,row,index){
                                    if(row.totleflow==null||row.totleflow==''){
                                        return 'N/A';
                                    }else{
                                        return parseFloat(row.totlerate).toFixed(2)+'%';
                                    }

                            }},
                            {field: 'comment',title: __('备注'),placeholder: __('模糊查询'),operate: 'LIKE %...%',formatter: function (value, row, index) {
                                 if(value.replace(/\s*/g,"")){
                                    return '<div style="min-width:50px;">' + value + '</div><input type="text" class="form-control text-center" data-field="' + this.field + '" style="width:100%;display:none;min-width:50px;" value="' + value + '">';

                                 }else{
                                    return '<div style="min-width:50px;">' + '<span>&nbsp;</span>'+ '</div><input type="text" class="form-control text-center" data-field="' + this.field + '" style="width:100%;display:none;min-width:50px;" value="">';

                                 }
                            }, events: {
                                'click div': function (e, value, row, index) {

                                    $(this).hide();
                                    $(this).next().show().focus();
                                },
                                'keyup input': function (e, value, row, index) {
                                    if (e.keyCode == 13 || e.keyCode == 10) {
                                        $(this).trigger("blur");
                                    }
                                },
                                'blur input': function (e, value, row, index) {
                                    var that = this;
                                    var values = $(this).val();
                                    var values1=$(this).prev().text();
                                    if(values1.replace(/\s*/g,"")=="" && values.replace(/\s*/g,"") == ""){
                                        $(that).hide();
                                        $(that).prev().show();
                                        $(that).prev().html('<span>&nbsp;</span>').show();
                                        $(that).attr("value","");
                                        return false;
                                    }
                                    if (values1 != values) {
                                        var data = {};
                                        data["row[" + $(that).data("field") + "]"] = values;
                                        Fast.api.ajax({
                                            url:  "point/regionday/editcomment?ids=" + row.id,
                                            data: data
                                        }, function (data, ret) {
                                            $(that).hide();
                                            if(values.replace(/\s*/g,"") == ""){
                                                $(that).prev().html('<span>&nbsp;</span>').show();
                                                $(that).attr("value","");
                                            }else{
                                                $(that).prev().text(values).show();
                                                $(that).attr("value",values);
                                            }
                                        });
                                    } else {
                                        $(that).hide();
                                        $(that).prev().show();
                                    }
                                }
                            }}
                            /*,
                            {field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                            buttons: [
                            {
                                name: 'addtabs',
                                text: '标签监控',
                                title: '标签监控',
                                icon: 'fa fa-pie-chart',
                                classname: 'btn btn-xs btn-info btn-addtabs',
                                url: '/admin/region/tag/index/ids/',
                                visible: function (row,full) {
                                    full.url ='/admin/region/tag/index/ids/'+tag_id+'?ref=addtabs';
                                    return true;
                                 }
                            }]}*/
                        ]
                    ],
                    //禁用默认搜索
                    showExport: false,
                    showToggle: false,
                    showColumns: false,
                    search: false,
                    //启用普通表单搜索
                    commonSearch: false,
                    //可以控制是否默认显示搜索单表,false则隐藏,默认为false
                    searchFormVisible: false,
                    pagination: false
                    //分页大小
                    //pageSize: 12

                });
                //在表格内容渲染完成后回调的事件
                table4.on('post-body.bs.table', function (e, data) {
                    $(".btn-editone").hide();
                    $(".btn-delone").hide();
                    Controller.mergeTable(table4,"regionname");
                    $.mergeRows("table4",1,[6,7]);
                    //$.mergeRows("table4",0);
                    //Controller.mergetabRows("table4",1,[6,7]);
                    //Controller.mergetabRows("table4",0);

                });
                // 为表格3绑定事件
                Table.api.bindevent(table4);

         },
         table2:function(){
            var time=$("#daytime").val();
            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            $.ajax({
                type:"POST",
                url: "point/regionday/table2",
                data:{ids:ids,time:time,name:name},
                dataType:"json",
                async: false,
                success:function(json){
                    var divs = document.getElementById("myTabContent");
                    var widths = divs.clientWidth||divs.offsetWidth;
                    var wrapwidth=widths-20;
                    var tabwidth=widths-10;
                    if(json.data.length>10){
                       tabwidth=tabwidth+json.data.length*25;
                       $(".wrap").attr('style','width: '+wrapwidth+'px;overflow-y:scroll;overflow-x:scroll');
                       $(".wraptab").attr('style','width: '+tabwidth+'px;text-align:center');
                    }else{
                        $(".wrap").attr('style','width:100%;overflow-y:auto;overflow-x:auto');
                        $(".wraptab").attr('style','width:100%;text-align:center');
                    }

                    $("#thtext2").hide();
                    var _html1 = '';
                    var _html2 = '';
                    $.each(json.data,function(k,v){
                        _html1 += "<th style='text-align: center;'>"+v.name+"</th>";
                    })
                    var colsjs=json.arr_name.length;
                    $.each(json.arr_name,function(k1,v1){
                        _html2 += "<tr style='text-align: center;'>";
                        $.each(json.data,function(k2,v2){
                            var keyval="value"+k1;
                            if((v2.name=="考核指标"||v2.name=="结算平均值")&&keyval=="value0"){
                                _html2 +="<td rowspan='"+colsjs+"' style='vertical-align: inherit;'>"+v2[keyval]+"</td>";
                            }else if(v2.name!="考核指标"&&v2.name!="结算平均值"){
                                _html2 +="<td >"+v2[keyval]+"</td>";

                            }
                        })
                         _html2 +="</tr>";
                    })
                    $("#nameth2").html(_html1);
                    $("#nametb2").html(_html2);
                }
            });
        },
        hskwtable:function(){
            var time=$("#daytime").val();

            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            $.ajax({
                type:"POST",
                url: "point/regionday/hskwtable",
                data:{ids:ids,time:time,name:name},
                dataType:"json",
                async: false,
                success:function(json){
                    var divs = document.getElementById("myTabContent");
                    var widths = divs.clientWidth||divs.offsetWidth;
                    var wrapwidth=widths-20;
                    var tabwidth=widths-10;
                    if(json.data.length>10){
                       tabwidth=tabwidth+json.data.length*25;
                       $(".wrap").attr('style','width: '+wrapwidth+'px;overflow-y:scroll;overflow-x:scroll');
                       $(".wraptab").attr('style','width: '+tabwidth+'px;text-align:center');
                    }else{
                        $(".wrap").attr('style','width:100%;overflow-y:auto;overflow-x:auto');
                        $(".wraptab").attr('style','width:100%;text-align:center');
                    }

                    $("#thtext6").hide();
                    var _html1 = '';
                    var _html2 = '';
                    var _html3 = '';//比例=吐流/回源
                    var _tr1 = '';//考核指标部分
                    if(json.band=="undefined"||json.band=="N/A"||json.band==null||json.band==""){
                        var band='N/A';
                    }else{
                        var band=parseFloat(json.band).toFixed(2);
                    }
                    if(json.outflow==null||json.outflow==""||json.outflow=="undefined"||json.outflow=="N/A"||json.band=="undefined"||json.band=="N/A"||json.band==null||json.band==""){
                        var chaz='N/A';
                        var aa='N/A';
                    }else{
                        var outflow=parseFloat(json.outflow).toFixed(2);
                        var chaz=parseFloat(outflow-band).toFixed(2);
                        var aa='达标';
                        if(chaz<0){
                            aa='不达标';
                        }
                    }

                    $.each(json.data,function(k,v){
                        var cols="";
                        if(v.name=="结算值"){
                            cols=" colspan='2'";
                        }
                        if(k==0){
                            _html1 += "<th style='text-align: center;width: 300px;word-wrap: break-word;' "+cols+">"+v.name+"</th>";
                        }else{
                            _html1 += "<th style='text-align: center;' "+cols+">"+v.name+"</th>";
                        }
                        if(k>1){
                            _tr1+= "<td> </td>";
                        }
                    })

                    $.each(json.arr_name,function(k1,v1){
                        //if(v1!="缓存流量"&&v1!="缓存流量回源"){
                            _html2 += "<tr style='text-align: center;'>";
                            $.each(json.data,function(k2,v2){
                                var keyval="value"+k1;
                                //console.log(keyval);
                                var cols="";
                                if(k2==1){
                                    cols=" colspan='2'";
                                    _html2 +="<td "+cols+">"+v2[keyval]+"</td>";
                                }else if(k2==0){
                                    _html2 +="<td><a href='#' class='contendhref' contend='"+v2["contend_id"+k1]+"' name='"+v1+"'>"+v2[keyval]+"</a></td>";
                                }else{
                                    _html2 +="<td "+cols+">"+v2[keyval]+"</td>";
                                }


                            })
                             _html2 +="</tr>";
                        //}
                    })
                    var colsjs=json.data.length;
                    $.each(json.dataAll,function(ks,vs){
                        _html2 += "<tr style='text-align: center;'><td>"+vs.name+"</td><td colspan='2'>"+vs.value1+"</td>";
                        var n=2;
                        //console.log(colsjs);
                        while(n<colsjs){
                            _html2 +="<td>"+vs["value"+n]+"</td>";
                            n++;
                        }
                        _html2 +="</tr>";
                    })
                    _html2 +="<tr>\
                                <td rowspan='3' style='vertical-align: inherit;' >考核指标 - 总流量(G)</td>\
                                <td colspan='2'>"+band+"</td>\
                                "+ _tr1+"</tr><tr>\
                                <td>是否达标</td>\
                                <td>差值</td>\
                                "+ _tr1+"</tr><tr>\
                                <td>"+aa+"</td>\
                                <td>"+chaz+"</td>\
                                "+ _tr1+"</tr>";
                    $("#nameth6").html(_html1);
                    $("#tbo6").html(_html2);
                }
            });
        },
        ghtable:function(){
            var time=$("#daytime").val();

            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            $.ajax({
                type:"POST",
                url: "point/regionday/ghtable",
                data:{ids:ids,time:time,name:name},
                dataType:"json",
                async: false,
                success:function(json){
                    var divs = document.getElementById("myTabContent");
                    var widths = divs.clientWidth||divs.offsetWidth;
                    var wrapwidth=widths-20;
                    var tabwidth=widths-10;
                    if(json.data.length>10){
                       tabwidth=tabwidth+json.data.length*25;
                       $(".wrap").attr('style','width: '+wrapwidth+'px;overflow-y:scroll;overflow-x:scroll');
                       $(".wraptab").attr('style','width: '+tabwidth+'px;text-align:center');
                    }else{
                        $(".wrap").attr('style','width:100%;overflow-y:auto;overflow-x:auto');
                        $(".wraptab").attr('style','width:100%;text-align:center');
                    }

                    $("#thtext5").hide();
                    var _html1 = '';
                    var _html2 = '';
                    var _html3 = '';//比例=吐流/回源
                    var _tr1 = '';//考核指标部分
                    if(json.band=="undefined"||json.band=="N/A"||json.band==null||json.band==""){
                        var band='N/A';
                    }else{
                        var band=parseFloat(json.band).toFixed(2);
                    }
                    if(json.outflow==null||json.outflow==""||json.outflow=="undefined"||json.outflow=="N/A"||json.band=="undefined"||json.band=="N/A"||json.band==null||json.band==""){
                        var chaz='N/A';
                        var aa='N/A';
                    }else{
                        var outflow=parseFloat(json.outflow).toFixed(2);
                        var chaz=parseFloat(outflow-band).toFixed(2);
                        var aa='达标';
                        if(chaz<0){
                            aa='不达标';
                        }
                    }

                    $.each(json.data,function(k,v){
                        var cols="";
                        if(v.name=="结算值"){
                            cols=" colspan='2'";
                        }
                        _html1 += "<th style='text-align: center;' "+cols+">"+v.name+"</th>";

                        if(k>1){
                            _tr1+= "<td> </td>";
                        }
                    })

                    $.each(json.arr_name,function(k1,v1){
                        _html2 += "<tr style='text-align: center;'>";
                        $.each(json.data,function(k2,v2){
                            var keyval="value"+k1;
                            //console.log(keyval);
                            var cols="";

                            if(k2==1){
                                cols=" colspan='2'";
                                _html2 +="<td "+cols+">"+v2[keyval]+"</td>";
                            }else if(k2==0){
                                _html2 +="<td><a href='#' class='contendhref' contend='"+v2["contend_id"+k1]+"' name='"+v1+"'>"+v2[keyval]+"</a></td>";
                            }else{
                                 _html2 +="<td "+cols+">"+v2[keyval]+"</td>";
                            }

                        })
                         _html2 +="</tr>";

                    })
                    var colsjs=json.data.length-2;
                    _html2 +="<tr>\
                                <td rowspan='3' style='vertical-align: inherit;' >考核指标 - 总流量(G)</td>\
                                <td colspan='2'>"+band+"</td>\
                                "+ _tr1+"</tr><tr>\
                                <td>是否达标</td>\
                                <td>差值</td>\
                                "+ _tr1+"</tr><tr>\
                                <td>"+aa+"</td>\
                                <td>"+chaz+"</td>\
                                "+ _tr1+"</tr>";
                    $("#nameth5").html(_html1);
                    $("#tbo5").html(_html2);
                }
            });
        },
        bflhtable:function(){
            var time=$("#daytime").val();

            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            $.ajax({
                type:"POST",
                url: "point/regionday/bflhtable",
                data:{ids:ids,time:time,name:name},
                dataType:"json",
                async: false,
                success:function(json){
                    var divs = document.getElementById("myTabContent");
                    var widths = divs.clientWidth||divs.offsetWidth;
                    var wrapwidth=widths-20;
                    var tabwidth=widths-10;
                    var tabeawidth=widths-35;
                    if(json.data.length>10){
                       tabwidth=tabwidth+json.data.length*25;
                       $(".wrap").attr('style','width: '+wrapwidth+'px;overflow-y:scroll;overflow-x:scroll');
                       $(".wraptab").attr('style','width: '+tabwidth+'px;text-align:center');
                       $("#tablea7").css({'width':+tabeawidth+'px','text-align':'center','margin-bottom': '40px'});
                    }else{
                        $(".wrap").attr('style','width:100%;overflow-y:auto;overflow-x:auto');
                        $(".wraptab").attr('style','width:100%;text-align:center');
                        //$("#tablea7").css('width: '+tabeawidth+'px;text-align:center;margin-bottom: 40px');
                    }

                    $("#thtext7").hide();
                    var _html1 = '';
                    var _html2 = '';
                    var _html3 = '';//比例=吐流/回源
                    var _tr1 = '';//考核指标部分
                    var bandra=json.topData["topbandrate"];
                    if(bandra!='N/A'){
                        bandra=bandra+' %';
                    }
                    var _trhtml = "<td style='text-align: center;' >"+json.topData["name"]+"</td>\
                                  <td style='text-align: center;' >"+json.topData["time"]+"</td>\
                                  <td style='text-align: center;' >出口</td>\
                                  <td style='text-align: center;' >"+json.topData["topname"]+"</td>\
                                  <td style='text-align: center;' >"+json.topData["bandsum"]+"</td>\
                                  <td style='text-align: center;' >"+json.topData["topvalue"]+"</td>\
                                  <td style='text-align: center;' >"+bandra+"</td>";


                    $("#tr7").html(_trhtml);
                    $.each(json.data,function(k,v){
                        var cols="";
                        if(v.name=="结算值"){
                            cols=" colspan='2'";
                        }
                        _html1 += "<th style='text-align: center;' "+cols+">"+v.name+"</th>";
                        if(k>2){
                            _tr1+= "<td> </td>";
                        }
                    })
                    //出口名称
                    $.each(json.arr_name,function(k1,v1){
                        _html2 += "<tr style='text-align: center;'>";
                        var data2=json.dataAll;
                        $.each(json.data,function(k2,v2){

                            var keyval="value"+k1;
                            var cols="";

                            if(v2.name!="流量项目"){
                                if(v2.name=="结算值"){
                                    cols=" colspan='2'";
                                    if(v2["banduseval"+k1]=='0'){
                                        var bandrats=v2["bandrate"+k1];
                                        if(bandrats!='N/A'){
                                            bandrats=bandrats+' %';
                                        }
                                        _html2 +="<td>带宽使用率</td><td>"+bandrats+"</td>";
                                    }else{
                                        _html2 +="<td "+cols+">"+v2[keyval]+"</td>";
                                    }

                                }else if(v2.name=="各项指标"){
                                    _html2 +="<td><a href='#' class='contendhref' contend='"+v2["contend_id"+k1]+"' name='"+v1+"'>"+v2[keyval]+"</a></td>";
                                }else{
                                    _html2 +="<td>"+v2[keyval]+"</td>";
                                }


                            }else{
                                var rows="1";
                                $.each(data2,function(ks,vs){
                                    if(ks==v2[keyval]){
                                        if(vs!='N/A'){
                                            rows=" rowspan="+vs;
                                            data2[ks]='N/A';
                                        }else{
                                            rows=vs;
                                        }
                                    }
                                })
                                if(rows!="N/A"){
                                    _html2 +="<td style='vertical-align: inherit;'"+rows+">"+v2[keyval]+"</td>";
                                }
                            }
                        })
                         _html2 +="</tr>";

                    })
                    //拼接净流量   
                    var colsjs=json.data.length;
                    $.each(json.dataSum,function(ks,vs){
                        if(vs.name!="as"&&vs.name!=""){
                            _html2 += "<tr style='text-align: center;'><td></td><td>"+vs.name+"</td><td colspan='2'>"+vs.value2+"</td>";
                            var n=3;
                            while(n<colsjs){
                                _html2 +="<td>"+vs["value"+n]+"</td>";
                                n++;
                            }
                            _html2 +="</tr>"; 
                        }
                        
                    })
                    var rowspanjs=json.jsList.length+1;
                    var colsjs=json.data.length-2;
                    //console.log(_tr1);
                    _html2 +="<tr>\
                                <td rowspan='"+rowspanjs+"' style='vertical-align: inherit;' >考核指标</td>\
                                <td></td>\
                                <td>是否达标</td>\
                                <td>差值</td>\
                                "+ _tr1+"</tr>";
                    $.each(json.jsList,function(ks,vs){

                        if(vs.expband==null||vs.expband==""||vs.expband=="undefined"||vs.expband=="N/A"||vs.value=="undefined"||vs.value=="N/A"||vs.value==null||vs.value==""){
                            var chaz='N/A';
                            var aa='N/A';
                        }else{
                            var band=parseFloat(vs.expband).toFixed(2);
                            var outflow=parseFloat(vs.value).toFixed(2);
                            var chaz=parseFloat(outflow-band).toFixed(2);
                            var aa='达标';
                            if(chaz<0){
                                aa='不达标';
                            }
                        }
                        _html2 += "<tr style='text-align: center;'><td>"+vs.name+"</td><td>"+aa+"</td><td>"+chaz+"</td>"+ _tr1+"</tr>";
                    })

                    $("#nameth7").html(_html1);
                    $("#tbo7").html(_html2);
                }
            });
        },
        table3:function(){
            var time=$("#daytime").val();

            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            $.ajax({
                type:"POST",
                url: "point/regionday/table3",
                data:{ids:ids,time:time,name:name},
                dataType:"json",
                async: false,
                success:function(json){
                    var divs = document.getElementById("myTabContent");
                    var widths = divs.clientWidth||divs.offsetWidth;
                    var wrapwidth=widths-20;
                    var tabwidth=widths-10;
                    if(json.data.length>10){
                       tabwidth=tabwidth+json.data.length*25;
                       $(".wrap").attr('style','width: '+wrapwidth+'px;overflow-y:scroll;overflow-x:scroll');
                       $(".wraptab").attr('style','width: '+tabwidth+'px;text-align:center');
                    }else{
                        $(".wrap").attr('style','width:100%;overflow-y:auto;overflow-x:auto');
                        $(".wraptab").attr('style','width:100%;text-align:center');
                    }

                    $("#thtext3").hide();
                    var _html1 = '';
                    var _html2 = '';
                    var _html3 = '';//比例=吐流/回源
                    var _tr1 = '';//考核指标部分
                    if(json.band=="undefined"||json.band=="N/A"||json.band==null||json.band==""){
                        var band='N/A';
                    }else{
                        var band=parseFloat(json.band).toFixed(2);
                    }
                    if(json.outflow==null||json.outflow==""||json.outflow=="undefined"||json.outflow=="N/A"||json.band=="undefined"||json.band=="N/A"||json.band==null||json.band==""){
                        var chaz='N/A';
                        var aa='N/A';
                    }else{
                        var outflow=parseFloat(json.outflow).toFixed(2);
                        var chaz=parseFloat(outflow-band).toFixed(2);
                        var aa='达标';
                        if(chaz<0){
                            aa='不达标';
                        }
                    }

                    $.each(json.data,function(k,v){
                        var cols="";
                        if(v.name=="结算值"){
                            cols=" colspan='2'";
                        }
                        _html1 += "<th style='text-align: center;' "+cols+">"+v.name+"</th>";
                        if(k>1){
                            _tr1+= "<td> </td>";
                        }
                    })

                    $.each(json.arr_name,function(k1,v1){
                        if(v1!="缓存流量"&&v1!="缓存流量回源"){
                            _html2 += "<tr style='text-align: center;'>";
                            $.each(json.data,function(k2,v2){
                                var keyval="value"+k1;
                                //console.log(keyval);
                                var cols="";
                               /* if(v2.name=="结算值"){
                                    cols=" colspan='2'";
                                }*/
                                if(k2==1){
                                    cols=" colspan='2'";
                                    _html2 +="<td "+cols+">"+v2[keyval]+"</td>";
                                }else if(k2==0){
                                    _html2 +="<td><a href='#' class='contendhref' contend='"+v2["contend_id"+k1]+"' name='"+v1+"'>"+v2[keyval]+"</a></td>";
                                }else{
                                    _html2 +="<td "+cols+">"+v2[keyval]+"</td>";
                                }

                            })
                             _html2 +="</tr>";
                        }
                    })
                    var colsjs=json.data.length-2;
                    $.each(json.dataAll,function(ks,vs){
                        var names='缓存流量';
                        if(ks=='a2'){
                            var names='缓存流量回源';
                        }
                        if(ks=='a3'){
                            _html2 += "<tr style='text-align: center;'><td>"+vs.name+"</td><td colspan='2'>"+vs.name1+"</td>";

                        }else{
                            _html2 += "<tr style='text-align: center;'><td><a href='#' class='contendhref' contend='"+vs["contend_id1"]+"' name='"+names+"'>"+vs.name+"</a></td><td colspan='2'>"+vs.name1+"</td>";
                        }
                        var n=0;
                        while(n<colsjs){
                            _html2 +="<td>"+vs["value"+n]+"</td>";
                            n++;
                        }
                        _html2 +="</tr>";
                    })
                    _html2 +="<tr>\
                                <td rowspan='3' style='vertical-align: inherit;' >考核指标 - 总流量(G)</td>\
                                <td colspan='2'>"+band+"</td>\
                                "+ _tr1+"</tr><tr>\
                                <td>是否达标</td>\
                                <td>差值</td>\
                                "+ _tr1+"</tr><tr>\
                                <td>"+aa+"</td>\
                                <td>"+chaz+"</td>\
                                "+ _tr1+"</tr>";
                    $("#nameth3").html(_html1);
                    $("#tbo").html(_html2);
                }
            });
        },
        table3111:function(){

            var time=$("#daytime").val();

            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            $.ajax({
                type:"POST",
                url: "point/regionday/table3",
                data:{ids:ids,time:time,name:name},
                dataType:"json",
                async: false,
                success:function(json){
                    var divs = document.getElementById("myTabContent");
                    var widths = divs.clientWidth||divs.offsetWidth;
                    var wrapwidth=widths-20;
                    var tabwidth=widths-10;
                    if(json.data.length>10){
                       tabwidth=tabwidth+json.data.length*25;
                       $(".wrap").attr('style','width: '+wrapwidth+'px;overflow-y:scroll;overflow-x:scroll');
                       $(".wraptab").attr('style','width: '+tabwidth+'px;text-align:center');
                    }else{
                        $(".wrap").attr('style','width:100%;overflow-y:auto;overflow-x:auto');
                        $(".wraptab").attr('style','width:100%;text-align:center');
                    }

                    $("#thtext3").hide();
                    var _html1 = '';
                    var _html2 = '';
                    var _html3 = '';
                    var _html4 = '';
                    var _tr1 = '';
                    var _html5 = '';
                    if(json.band=="undefined"||json.band=="N/A"||json.band==null||json.band==""){
                        var band='N/A';
                    }else{
                        var band=parseFloat(json.band).toFixed(2);
                    }
                    if(json.outflow==null||json.outflow==""||json.outflow=="undefined"||json.outflow=="N/A"||json.band=="undefined"||json.band=="N/A"||json.band==null||json.band==""){
                        var chaz='N/A';
                        var aa='N/A';
                    }else{
                        var outflow=parseFloat(json.outflow).toFixed(2);
                        var chaz=parseFloat(outflow-band).toFixed(2);
                        var aa='达标';
                        if(chaz<0){
                            aa='不达标';
                        }
                    }
                    $.each(json.data,function(k,v){
                        var cols="";
                        if(v.name=="结算值"){
                            cols=" colspan='2'";
                        }
                        _html1 +="<th style='text-align: center;' "+cols+">"+v.name+"</th>";
                        _html2 +="<td "+cols+">"+v.value1+"</td>";
                        _html3 +="<td "+cols+">"+v.value2+"</td>";
                        _html4 +="<td "+cols+">"+v.value3+"</td>";
                        if(k>1){
                            _tr1+= "<td> </td>";
                        }

                    })

                    _html5 ="<tr>\
                                <td rowspan='3' style='vertical-align: inherit;' >考核指标 - 总流量(G)</td>\
                                <td colspan='2'>"+band+"</td>\
                                "+ _tr1+"</tr><tr>\
                                <td>是否达标</td>\
                                <td>差值</td>\
                                "+ _tr1+"</tr><tr>\
                                <td>"+aa+"</td>\
                                <td>"+chaz+"</td>\
                                "+ _tr1+"</tr>";
                    $("#nameth3").html(_html1);
                    $("#tbo").append("<tr>"+_html2+"</tr>");
                    $("#tbo").append("<tr>"+_html3+"</tr>");
                    $("#tbo").append("<tr>"+_html4+"</tr>");
                    $("#tbo").append(_html5);
                }
            });
        },
        requestdata:function(){
            var time=$("#daytime").val();
            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            $.ajax({
                type:"POST",
                url: "point/regionday/requestdata",
                data:{ids:ids,time:time,name:name},
                dataType:"json",
                async: false,
                success:function(json){
                    if(json.data.length==0){
                        var tolband ='N/A';
                        var expotband ='N/A';
                        var expotrate ='N/A';
                        var lanrate ='N/A';
                    }else{
                        var tolband = parseFloat(json.tolband).toFixed(2);
                        var expotband = parseFloat(json.expotband).toFixed(2);
                        var expotrate = expotband;
                        var lanrate=tolband;
                        if(tolband!='0.00'){
                            expotrate = (100*expotband/tolband).toFixed(2);
                            lanrate=(100-expotrate).toFixed(2);
                        }
                        lanrate=lanrate+"%";
                        expotrate=expotrate+"%";
                    }
                    var _html = "<td style='text-align: center;' >"+tolband+"</td>\
                                  <td style='text-align: center;' >"+expotband+"</td>\
                                  <td style='text-align: center;' >"+lanrate+"</td>\
                                  <td style='text-align: center;' >"+expotrate+"</td>";


                    $("#tr1").html(_html);
                    if(json.data.length>0){
                        Controller.requestpercentdraw(json.data,"regionlink1");
                        Controller.requestpercentdraw(json.data1,"regionlink2");
                    }

                }
            });

        },
        // 列表
        probequality:function(toolbarId,tableId){
            var table = $("#"+tableId);

            var time=$("#daytime").val();


            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            table.bootstrapTable('refresh');
            table.bootstrapTable('destroy');
            table.bootstrapTable({
                    url:'point/regionday/table',
                    //url:'point/regionday/table?name='+name+'&ids='+ids+'&time='+time,
                    extend: {
                        table: 'region_monitor_contentday',
                    },
                    toolbar: toolbarId,
                    //sortName: 'a.id',
                    columns: [
                        [
                            /*{field: 'id', title:__('ID'),formatter: function(value,row,index){
                                    return row.id;
                            }},*/
                            {field: 'regionname', title:__('项目名称')},
                            {field: 'everyDay', title: __('日期'), operate:'RANGE', addclass:'datetimerange',formatter:function(value,row,index){
                                var oldTime = (new Date(value)).getTime();
                                return new Date(oldTime).Format("yyyy年MM月dd日");
                            }},
                            {field: 'resourcename', title: __('资源'),operate:false,placeholder: __('模糊查询')},
                            {field: 'exportname', title: __('出口'),operate:false,placeholder: __('模糊查询'),formatter:function(value,row,index){
                                if(value==null||value==''){
                                    return '-';
                                }else{
                                    return "<a href='#'>"+value+"</a>";
                                }}
                                , events: {
                                  'click a': function (e, value, row, index) {
                                    Fast.api.open("/screen/drawing/detail?id="+row.contend_id+'&name='+row.exportname+'&type=5',row.exportname+"-趋势图",{area:['80%', '88%']});
                                  }}
                            },
                            {field: 'band', title: __('带宽(G)'),operate:false,formatter:function(value,row,index){
                                if(value==null||value==''){
                                    return 'N/A';
                                }else{
                                    return parseFloat(value).toFixed(2);
                                }

                            }},
                            {field: 'values', title: __('实际使用带宽(G)'),operate:false,formatter:function(value,row,index){
                                return (row.values/1000000000).toFixed(2);
                            }},
                            {field: 'valuserate', title: __('带宽使用率'),cellStyle:Controller.cellStyle,operate:false,formatter:function(value,row,index){
                                if(row.band==null||row.band==''){
                                    return 'N/A';
                                }else{
                                     return row.valuserate+'%';
                                }

                            }},
                            /*{field: 'exportstatus', title: __('出口计算'),searchList:{"1":__('正'),"0":__('负')},align: 'center',formatter: Table.api.formatter.status},*/
                            {field: 'totleflow', title: __('实际流量(G)'),operate:false,formatter:function(value,row,index){
                                if(row.totleflow==null||row.totleflow==''){
                                    return 'N/A';
                                }else{
                                     return parseFloat(row.totleflow).toFixed(2);
                                }
                            }},
                            {field: 'totlerate', title: __('服务流量占比'),cellStyle:Controller.serverPercent,operate:false,formatter:function(value,row,index){
                                if(row.totleflow==null||row.totleflow==''){
                                    return 'N/A';
                                }else{
                                    return parseFloat(row.totlerate).toFixed(2)+'%';
                                    /*if(parseFloat(row.totlerate).toFixed(2) < 45) {
                                        return '<div class="progress progress-striped"> <div class="progress-bar progress-bar-warning" style="width:'+parseFloat(row.totlerate).toFixed(2)+'%"></div>'+parseFloat(row.totlerate).toFixed(2)+'%'+'</div>';
                                    } else {
                                        return '<div class="progress progress-striped"> <div class="progress-bar progress-bar-warning" style="width:'+parseFloat(row.totlerate).toFixed(2)+'%">'+parseFloat(row.totlerate).toFixed(2)+'%'+'</div></div>';
                                    }*/
                                }
                            }},
                            {field: 'comment',title: __('备注'),placeholder: __('模糊查询'),operate: 'LIKE %...%',formatter: function (value, row, index) {
                                 if(value.replace(/\s*/g,"")){
                                    return '<div style="min-width:50px;">' + value + '</div><input type="text" class="form-control text-center" data-field="' + this.field + '" style="width:100%;display:none;min-width:50px;" value="' + value + '">';

                                 }else{
                                    return '<div style="min-width:50px;">' + '<span>&nbsp;</span>'+ '</div><input type="text" class="form-control text-center" data-field="' + this.field + '" style="width:100%;display:none;min-width:50px;" value="">';

                                 }
                            }, events: {
                                'click div': function (e, value, row, index) {

                                    $(this).hide();
                                    $(this).next().show().focus();
                                },
                                'keyup input': function (e, value, row, index) {
                                    if (e.keyCode == 13 || e.keyCode == 10) {
                                        $(this).trigger("blur");
                                    }
                                },
                                'blur input': function (e, value, row, index) {
                                    var that = this;
                                    var values = $(this).val();
                                    var values1=$(this).prev().text();
                                    if(values1.replace(/\s*/g,"")=="" && values.replace(/\s*/g,"") == ""){
                                        $(that).hide();
                                        $(that).prev().show();
                                        $(that).prev().html('<span>&nbsp;</span>').show();
                                        $(that).attr("value","");
                                        return false;
                                    }
                                    if (values1 != values) {
                                        var data = {};
                                        data["row[" + $(that).data("field") + "]"] = values;
                                        Fast.api.ajax({
                                            url:  "point/regionday/editcomment?ids=" + row.id,
                                            data: data
                                        }, function (data, ret) {
                                            $(that).hide();
                                            if(values.replace(/\s*/g,"") == ""){
                                                $(that).prev().html('<span>&nbsp;</span>').show();
                                                $(that).attr("value","");
                                            }else{
                                                $(that).prev().text(values).show();
                                                $(that).attr("value",values);
                                            }
                                        });
                                    } else {
                                        $(that).hide();
                                        $(that).prev().show();
                                    }
                                }
                            }}
                            /*,
                            {field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                            buttons: [
                            {
                                name: 'addtabs',
                                text: '标签监控',
                                title: '标签监控',
                                icon: 'fa fa-pie-chart',
                                classname: 'btn btn-xs btn-info btn-addtabs',
                                url: '/admin/region/tag/index/ids/',
                                visible: function (row,full) {
                                    full.url ='/admin/region/tag/index/ids/'+tag_id+'?ref=addtabs';
                                    return true;
                                 }
                            }]}*/
                        ]
                    ],
                    //禁用默认搜索
                    showExport: false,
                    showToggle: false,
                    showColumns: false,
                    search: false,
                    //启用普通表单搜索
                    commonSearch: false,
                    //可以控制是否默认显示搜索单表,false则隐藏,默认为false
                    searchFormVisible: false,
                    pagination: false,
                    //分页大小
                    //pageSize: 12,
                    queryParams: function queryParams(params){
                      var param = {
                        pageNumber: params.pageNumber,
                        pageSize: params.pageSize,
                        //sortName: params.sortName,
                        sortOrder: params.sortOrder,
                        name: $("#name").html(),
                        ids: $("#ids").html(),
                        time: $("#daytime").val()
                       };
                       return param;
                    }
                });
                 //在表格内容渲染完成后回调的事件

                 table.on('post-body.bs.table', function (e, data) {
                    $(".btn-editone").hide();
                    $(".btn-delone").hide();
                    // $.mergeRows("table",5);
                    if(data.length>1){
                        Controller.mergeTable(table,"resourcename");
                        Controller.mergeTable(table,"regionname");
                        Controller.mergeTable(table,"everyDay");

                        setTimeout(function () {
                            Controller.mergetabRows(tableId,2,[7,8]);
                            //Controller.mergetabRows(tableId,2,7);
                            //Controller.mergetabRows(tableId,2,8);
                        }, 50);
                    }

                    $('tr').children("td").css("border","1px solid #444");
                    $('tr').children("th").css("border","1px solid #444");
                });

                // 为表格3绑定事件
                Table.api.bindevent(table);

        },
        // 绥化广电下列表
        probequalitysum:function(){
            var tablesum = $("#tablesum");

            var time=$("#daytime").val();


            var ids = $("#ids").html();
            var name = $("#name").html();
            var tag_id = $("#tag_id").html();
            tablesum.bootstrapTable('refresh');
            tablesum.bootstrapTable('destroy');
            tablesum.bootstrapTable({
                    url:'point/regionday/shtablesum',
                    //url:'point/regionday/huntable?name='+name+'&ids='+ids+'&time='+time,
                    extend: {
                        table: 'region_monitor_contentday',
                    },
                    toolbar: '#toolbarsum',
                    //sortName: 'a.id',
                    columns: [
                        [
                            /*{field: 'id', title:__('ID'),formatter: function(value,row,index){
                                    return row.id;
                            }},*/
                            {field: 'regionname', title:__('项目名称')},
                            {field: 'everyDay', title: __('日期'), operate:'RANGE', addclass:'datetimerange',formatter:function(value,row,index){
                                var oldTime = (new Date(value)).getTime();
                                return new Date(oldTime).Format("yyyy年MM月dd日");
                            }},
                            {field: 'resourcename', title: __('资源'),operate:false,placeholder: __('模糊查询')},
                            {field: 'exportname', title: __('出口'),operate:false,placeholder: __('模糊查询'),formatter:function(value,row,index){
                                if(value==null||value==''){
                                    return '-';
                                }else{
                                    return "<a href='#'>"+value+"</a>";
                                }}
                                , events: {
                                  'click a': function (e, value, row, index) {
                                    Fast.api.open("/screen/drawing/detail?id="+row.contend_id+'&name='+row.exportname+'&type=5',row.exportname+"-趋势图",{area:['80%', '88%']});
                                  }}
                              },
                            {field: 'band', title: __('带宽(G)'),operate:false,formatter:function(value,row,index){
                                if(value==null||value==''){
                                    return 'N/A';
                                }else{
                                     return parseFloat(value).toFixed(2);
                                }

                            }},
                            {field: 'bandmatchrate', title: __('带宽匹配值'),operate:false,formatter:function(value,row,index){
                                if(value==null||value==''){
                                    return 'N/A';
                                }else{
                                     return value+'%';
                                }

                            }},
                            {field: 'values', title: __('实际使用带宽(G)'),operate:false,formatter:function(value,row,index){
                                if(row.values==null||row.values==''){
                                    return 'N/A';
                                }else{
                                    return (row.values/1000000000).toFixed(2);
                                }
                            }},
                            {field: 'valuserate', title: __('带宽使用率'),cellStyle:Controller.cellStyle,operate:false,formatter:function(value,row,index){
                                if(row.band==null||row.band==''){
                                    return 'N/A';
                                }else{
                                     return row.valuserate+'%';
                                }

                            }},
                            /*{field: 'exportstatus', title: __('出口计算'),searchList:{"1":__('正'),"0":__('负')},align: 'center',formatter: Table.api.formatter.status},*/
                            /*{field: 'totleflow', title: __('实际流量(G)'),operate:false,formatter:function(value,row,index){
                                    return row.totleflow;
                            }},
                            {field: 'totlerate', title: __('服务流量占比'),operate:false,formatter:function(value,row,index){
                                     return row.totlerate+'%';
                            }},*/
                            {field: 'matchcomment',title: __('备注'),placeholder: __('模糊查询'),operate: 'LIKE %...%',formatter: function (value, row, index) {
                                 if(value){
                                    return '<div style="min-width:50px;">' + value + '</div><input type="text" class="form-control text-center" data-field="' + this.field + '" style="width:100%;display:none;min-width:50px;" value="' + value + '">';

                                 }else{
                                    return '<div style="min-width:50px;">' + '<span>&nbsp;</span>'+ '</div><input type="text" class="form-control text-center" data-field="' + this.field + '" style="width:100%;display:none;min-width:50px;" value="">';

                                 }
                            }, events: {
                                'click div': function (e, value, row, index) {

                                    $(this).hide();
                                    $(this).next().show().focus();
                                },
                                'keyup input': function (e, value, row, index) {
                                    if (e.keyCode == 13 || e.keyCode == 10) {
                                        $(this).trigger("blur");
                                    }
                                },
                                'blur input': function (e, value, row, index) {
                                    var that = this;
                                    var values = $(this).val();
                                    var values1=$(this).prev().text();
                                    if(values1.replace(/\s*/g,"")=="" && values.replace(/\s*/g,"") == ""){
                                        $(that).hide();
                                        $(that).prev().show();
                                        $(that).prev().html('<span>&nbsp;</span>').show();
                                        $(that).attr("value","");
                                        return false;
                                    }
                                    if (values1 != values) {
                                        var data = {};
                                        data["row[" + $(that).data("field") + "]"] = values;
                                        Fast.api.ajax({
                                            url:  "point/regionday/editmatchcomment?ids=" + row.id,
                                            data: data
                                        }, function (data, ret) {
                                            $(that).hide();
                                            if(values.replace(/\s*/g,"") == ""){
                                                $(that).prev().html('<span>&nbsp;</span>').show();
                                                $(that).attr("value","");
                                            }else{
                                                $(that).prev().text(values).show();
                                                $(that).attr("value",values);
                                            }
                                        });
                                    } else {
                                        $(that).hide();
                                        $(that).prev().show();
                                    }
                                }
                            }}
                            /*,
                            {field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                            buttons: [
                            {
                                name: 'addtabs',
                                text: '标签监控',
                                title: '标签监控',
                                icon: 'fa fa-pie-chart',
                                classname: 'btn btn-xs btn-info btn-addtabs',
                                url: '/admin/region/tag/index/ids/',
                                visible: function (row,full) {
                                    full.url ='/admin/region/tag/index/ids/'+tag_id+'?ref=addtabs';
                                    return true;
                                 }
                            }]}*/
                        ]
                    ],
                    //禁用默认搜索
                    showExport: false,
                    showToggle: false,
                    showColumns: false,
                    search: false,
                    //启用普通表单搜索
                    commonSearch: false,
                    //可以控制是否默认显示搜索单表,false则隐藏,默认为false
                    searchFormVisible: false,
                    pagination: false,
                    //分页大小
                    //pageSize: 12,
                    queryParams: function queryParams(params){
                      var param = {
                        pageNumber: params.pageNumber,
                        //pageSize: params.pageSize,
                        //sortName: params.sortName,
                        sortOrder: params.sortOrder,
                        name: $("#name").html(),
                        ids: $("#ids").html(),
                        time: $("#daytime").val()
                       };
                       return param;
                    }
                });
                 //在表格内容渲染完成后回调的事件
                 tablesum.on('post-body.bs.table', function (e, data) {
                    $(".btn-editone").hide();
                    $(".btn-delone").hide();

                    if(data.length>1){
                        setTimeout(function () {
                            Controller.mergeTable(tablesum,"resourcename");
                            Controller.mergeTable(tablesum,"regionname");
                            Controller.mergeTable(tablesum,"everyDay");
                            //Controller.mergetabRows("tablesum",2);

                        }, 10);
                    }
                    $('tr').children("td").css("border","1px solid #444");
                    $('tr').children("th").css("border","1px solid #444");
                });
                // 为表格3绑定事件
                Table.api.bindevent(tablesum);

        },
        // 标记树结构等级
        getlevel:function(ids){
            var datajson = "";
            $.ajax({
                type:"POST",
                url: "point/regionday/gettopid",
                data:{ids:ids},
                dataType:"json",
                async: false,
                success:function(data){
                    datajson = data;
                }
            });
            return datajson;
        },
        cellStyle:function(value,row, index) {
            var style = {};
            if(row.band!=null&&row.band!=''){
               style={css:{'background':'#00b050'}};
               if((row.valuserate>=90 && row.band<5)||(row.valuserate>=95 && row.band>=5)){
                   style={css:{'background':'#FFFF00'}};//黄色
                }
                if((row.valuserate>=95 && row.band<5)||(row.valuserate>=97 && row.band>=5)){
                    style={css:{'background':'red'}};//红色
                }
            }
            return style;
        },
        serverPercent: function(value, row, index) {
            var style = {};
            if (row.totlerate <= 30 && row.totlerate > 0) {
                style = {
                    css: {
                        'background': "url('/dashboards/images/red.png')",
                        'background-image': colorConfig.lower,
                        'background-size': row.totlerate + '% 100%',
                        "background-repeat": "no-repeat"
                    }
                };//蓝色
            }else if (row.totlerate > 30) {
                style = {
                    css: {
                        'background': "url('/dashboards/images/red.png')",
                        'background-image': colorConfig.higher,
                        'background-size': row.totlerate + '% 100%',
                        "background-repeat": "no-repeat"
                    }
                };//红色
            } else {
                style={};
            }
            return style;
        },
         //合并表格 ,丰装好了，可以直接结合代码使用
        mergeTable:function(bstable, fieldname){
            var rows = bstable.bootstrapTable('getData');
            var rowspan = 0;
            var index = 0;
            var first_yjzbmc = '';
            $.each(rows, function (i, row) {
                if (i == 0) {
                    first_yjzbmc = row[fieldname];
                    rowspan = 1;
                    index = i;
                } else {
                    if (first_yjzbmc === row[fieldname]) {
                        rowspan++;
                    }else {
                        $(bstable).bootstrapTable('mergeCells', { index: index, field: fieldname, colspan: 1, rowspan: rowspan });
                        first_yjzbmc = row[fieldname];
                        rowspan = 1;
                        index = i;
                    }
                    if (i == (rows.length - 1)) {
                        $(bstable).bootstrapTable('mergeCells', { index: index, field: fieldname, colspan: 1, rowspan: rowspan });
                    }
                }
            });
            $('tr').children("td").css("border","1px solid #444");
            $('tr').children("th").css("border","1px solid #444");
        },
        mergetabRows:function(tableId, col,acol){
            var listTable = document.getElementById(tableId);
            var trs = listTable.getElementsByTagName("tr");
            if (trs.length > 1) {
               for (var i = 1; i < trs.length - 1; i++) {
                    var rowSpans=trs[i].getElementsByTagName("td")[col].getAttribute('rowspan');
                    if(rowSpans){
                        $.each(acol,function(k1,v1){
                            if(trs[i].getElementsByTagName("td")[v1]){
                                trs[i].getElementsByTagName("td")[v1].rowSpan = rowSpans;
                                for (var j = 1; j < rowSpans; j++) {
                                    if(trs[j+i]){
                                       trs[j+i].getElementsByTagName("td")[v1].style.display = "none";
                                    }
                                }
                            }
                        });
                    }
               }
            }
        },
        requestpercentdraw:function(data,id){
                var data_arr = [];
                $.each(data,function(k,v){
                  data_arr.push(v.name);
                })
                option = {
                    title: {
                        text: '',
                        subtext: '',
                        left: 'center'
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: '{a} <br/>{b} : {c} G ({d}%)'
                    },
                    legend: {
                        orient: 'vertical',
                        left: 'left',
                        data:data_arr
                    },
                    series: [
                        {
                            name: '统计类型',
                            type: 'pie',
                            radius: '55%',
                            center: ['50%', '60%'],
                            label: {
                                normal: {
                                    formatter: '{b}:{d}%',
                                    backgroundColor: '#eee',
                                    borderWidth: 1,
                                    borderRadius: 4,
                                    //show: false
                                },
                            },
                            data:data,
                            /*data: [
                                {value: 335, name: '直接访问'},
                                {value: 310, name: '邮件营销'},
                                {value: 234, name: '联盟广告'},
                                {value: 135, name: '视频广告'},
                                {value: 1548, name: '搜索引擎'}
                            ],*/
                            emphasis: {
                                itemStyle: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }
                    ]
                };
                var myChart = echarts.init(document.getElementById(id));
                myChart.clear();
                myChart.setOption(option, true);
                window.addEventListener("resize", function () {
                    myChart.resize();
                });
                setInterval(function () {
                if ($("#"+id).width() != $("#"+id+" canvas").width() && $("#"+id+" canvas").width() < $("#"+id).width()) {
                    myChart.resize();
                }
            }, 700);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        detail:function(){

        },
        Format:function(fmt){
            Date.prototype.Format = function (fmt) {
                var o = {
                    "M+": this.getMonth() + 1, //月份
                    "d+": this.getDate(), //日
                    "H+": this.getHours(), //小时
                    "m+": this.getMinutes(), //分
                    "s+": this.getSeconds(), //秒
                    "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                    "S": this.getMilliseconds() //毫秒
                };
                if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
                for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                return fmt;
            }
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
        },

        //共用的方法   获取对象的长度
        objLength: function(obj){
            var count = 0;
            for(var i in obj){
                count ++;
            }
            return count;
        },

        piechart: function(json, type, id ,idname){ //画图 饼图/趋势图   数据   类型(画图的字段后期可扩展)  id
          var myChart = echarts.init(document.getElementById(id));
          var lengthdsname = [];
          for(var item of json.series) { // item代表数组里面的元素
            lengthdsname.push(item.name);
          };

          var flowname=type;
          if(flowname.length > 40){
            var temp = flowname.substring(0,40)+'...';
          }else{
            temp = flowname;
          }

          $('#'+idname).html(temp);
          $('#'+idname).attr("title", flowname);
          var text= temp;
          option = {
            tooltip: {
                trigger: 'axis',
                position:'inside',
                formatter:function(params, ticket, callback){
                    var tipString = params[0].name + "<br />";
                    var indexColor;
                    if(id.indexOf("property") != -1 ){
                        for (var i = 0, length = params.length; i < length; i++) {
                            if(params[i].value==""||params[i].value==null){
                                var item_val_str = 0+" %";
                            }else{
                                var item_val_str = params[i].value.toFixed(2)+" %";
                            }
                            indexColor = params[i].color;
                            tipString += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background:' + indexColor + '"></span>';
                            tipString += '<span style="color:#fff" data-type ="lineTip" data-val=' + params[i].value + '>' + params[i].seriesName + '：' + item_val_str + '</span><br />';
                        }
                    }else{
                        for (var i = 0, length = params.length; i < length; i++) {
                            var item_val = params[i].value;
                            if(item_val < 1000){
                                if(item_val==""||item_val==null){
                                    var item_val_str = 0+" bps";
                                }else{
                                    var item_val_str = item_val.toFixed(2)+" bps";
                                }
                               //var item_val_str = item_val.toFixed(2)+" bps";
                            }else if(1000 < item_val && item_val < 1000 * 1000){
                               var item_val_str = (item_val/(1000)).toFixed(2)+"Kbps";
                            }else if(1000 * 1000 <= item_val && item_val < 1000 * 1000 * 1000){
                               var item_val_str = (item_val/(1000*1000)).toFixed(2)+"Mbps";
                            }else if(1000 * 1000 * 1000 <= item_val && item_val < 1000 * 1000 * 1000 * 1000){
                               var item_val_str = (item_val/(1000*1000*1000)).toFixed(2)+"Gbps";
                            }
                            indexColor = params[i].color;
                            tipString += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background:' + indexColor + '"></span>';
                            tipString += '<span style="color:#fff" data-type ="lineTip" data-val=' + params[i].value / 1000 / 1000 + '>' + params[i].seriesName + '：' + item_val_str + '</span><br />';
                        }
                    }
                    return tipString;

                }
            },
            /*title: {
                left: 'center',
                text: text,
            },*/
            legend: {
                x: 'center',
                y:30,
                data:lengthdsname
             },
            toolbox: {
                feature: {
                    myTool1: {
                            show: true,
                            title: '推送到屏幕',
                            icon:'image:///assets/img/copy.png',
                            //icon: 'path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891',
                            onclick: function (){
                                $.ajax({
                                    url: 'general/screens/index',
                                    type:'post',
                                    //data: {ids:tag_id,names:names,starttime:starttime3,endtime:endtime3,gradename:gradename3},
                                    dataType:'json',
                                    success:function(json){
                                        if(json.total<1){
                                            Toastr.error("请先到屏幕维护-配置屏幕页面，配置屏幕名称");
                                        }else{
                                            var tag_id = $("#ids").html();
                                            Fast.api.open("resources/tag/add_screen/ids/"+tag_id+"?from=tag","选择屏幕");
                                        }
                                    }
                                });
                            }
                    },
                    dataZoom: {
                        yAxisIndex: 'none'
                    },
                    restore: {},
                    saveAsImage: {}
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data : json.xAxis,
                splitLine: {
                    show: true,
                    lineStyle: {
                        type: 'dashed'
                    }
                }
            },
            yAxis: {
                type: 'value',
                boundaryGap: [0, '100%'],
                axisLabel: {
                    formatter:function(item_val){
                        if(id.indexOf("property") != -1 ){
                            return Math.floor(item_val) + ' %';
                        }else{
                            if(item_val < 1000){
                               return Math.floor(item_val)+" bps";
                            }else if(1000 < item_val && item_val < 1000 * 1000){
                               return Math.floor(item_val/(1000))+"Kbps";
                            }else if(1000 * 1000 <= item_val && item_val < 1000 * 1000 * 1000){
                               return Math.floor(item_val/(1000*1000))+"Mbps";
                            }else if(1000 * 1000 * 1000 <= item_val && item_val < 1000 * 1000 * 1000 * 1000){
                               return Math.floor(item_val/(1000*1000*1000))+"Gbps";
                            }
                        }
                    },
                },
                splitLine: {
                    show: true,
                    lineStyle: {
                        type: 'dashed'
                    }
                }
            },
            dataZoom: [{
                show:true,
                //type: 'inside',//鼠标滚动影响图标拖动
                type: 'slider',
                start: 85,
                end: 100,
                zoomOnMouseWheel:false,
            }, {
                start: 0,
                end: 10,
                handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
                handleSize: '80%',
                handleStyle: {
                    color: '#fff',
                    shadowBlur: 3,
                    shadowColor: 'rgba(0, 0, 0, 0.6)',
                    shadowOffsetX: 2,
                    shadowOffsetY: 2
                }
            }],
            grid: [
                    {
                      left: '7%',
                      right: '10%',
                      width: '91%'
                  }

            ],
            series: [
                {
                    name:json.series[0].name,
                    type:'line',
                    smooth:true,
                    symbol: 'none',
                    sampling: 'average',
                    itemStyle: {
                        color: 'rgb(255, 70, 131)'
                    },
                    areaStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgb(255, 158, 68)'
                        }, {
                            offset: 1,
                            color: 'rgb(255, 70, 131)'
                        }])
                    },
                    data:json.series[0].data
                },{
                    name:json.series[1].name,
                    type:'line',
                    smooth:true,
                    symbol: 'none',
                    sampling: 'average',
                    itemStyle: {
                        color: 'rgb(255, 70, 131)'
                    },
                    areaStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgb(255, 158, 68)'
                        }, {
                            offset: 1,
                            color: 'rgb(255, 70, 131)'
                        }])
                    },
                    data:json.series[1].data
                }
            ]
          };
         //使用刚指定的配置项和数据显示图表
          myChart.clear();
          myChart.setOption(option,true);
          window.addEventListener("resize", function () {
            myChart.resize();
          });
          myChart.dispatchAction({ // 默认启动 toolbox 中 dataZoom 的区域缩放状态
                type: "takeGlobalCursor",
                key: "dataZoomSelect",
                dataZoomSelectActive: true
          });
          setInterval(function () {
                if ($("#"+id).width() != $("#"+id+" canvas").width() && $("#"+id+" canvas").width() < $("#"+id).width()) {
                    myChart.resize();
                }
            }, 700);

        },

    };
    return Controller;
});